<?php

require_once('Zend/Controller/Plugin/Abstract.php');

require_once('Zend/View.php');
require_once('Zend/Controller/Action/Helper/ViewRenderer.php');
require_once('Zend/Controller/Action/HelperBroker.php');
require_once('Cms/View/PhpTal.php');
require_once('Zend/Layout.php');

class View extends Zend_Controller_Plugin_Abstract
{
    public function routeShutdown(Zend_Controller_Request_Abstract $request)
    {
    	$CONFIG = Zend_Registry::get('config');

		$main = Zend_Controller_Front::getInstance();
		/* Make sure template cache files go into designated temp folder */
		
		if (!defined('PHPTAL_PHP_CODE_DESTINATION'))
		
		define('PHPTAL_PHP_CODE_DESTINATION', $CONFIG->path->temp.'/');
		
		Zend_Layout::startMvc(); 
		
		Zend_Layout::getMvcInstance()->setViewSuffix('html'); 
		
		//Initialize View Template Engine
		
		$vr = new Zend_Controller_Action_Helper_ViewRenderer();
		
		$view_engine = new Cms_View_PhpTal();
		//print_r($view_engine);
		$vr->setView($view_engine);
		$view_engine->siteTitle = 'Corjanta';
		
		$vr->setViewSuffix('html');
		$view_engine->addHelperPath('Cms/View/Helper/', 'Cms_View_Helper');
		$view_engine->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper');
		$view_engine->addHelperPath('Cms/Dojo/View/Helper/', 'Cms_Dojo_View_Helper');
		//print_r($vr);
		Zend_Controller_Action_HelperBroker::addHelper($vr);
    }
}